Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

286
Vistas
Next.js API routes all return "Interval Server Error" in production, but all the routes work in development

Whenever I go to any API route in my Next.js app in production it returns a 500 "Internal Server Error" but in development, all of them work completely fine and show/return what I expect them to.

another example of the error

the error

I am deploying with an AWS Ec2 instance.

the code is available here: https://github.com/123om123/NFT-Marketplace

These are all my API routes.

enter image description here

The [...auth0].js creates the following routes: /api/auth/login, /api/auth/logout, /api/auth/callback, and /api/auth/me

If I try to access the "find_account" API route like the following:

  let findAccount = async function () {
    await fetch("/api/find_account", {
      method: "POST",
      body: JSON.stringify({
        DBUrl: DBUrl,
        user_id: user.sub,
      }),
    })
      .then(async (response) => {
        await response.json().then((result) => {
          accountData = result;
          if (accountData.data.allAccounts.nodes[0].addresses !== null) {
            setAddressList(accountData.data.allAccounts.nodes[0].addresses[0].split(","));
          }
        });
      })
      .catch((err) => {
        return err;
      });
  };

which handles requests like the following:

export default function handler(req, res) {
  req.body = JSON.parse(req.body);
  fetch(req.body.DBUrl, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      query: `query MyQuery {
        allAccounts(condition: {userId:"${req.body.user_id}"}) {
          nodes {
            addresses
          }
        }
      }`,
    }),
  })
    .then((response) => {
      response.json().then((response) => {
        res.status(200).send(response);
      });
    })
    .catch((err) => {
      res.status(500).send(err);
    });
}

it works fine and returns the response from the graphql API in development, but in production it shows the above error.

The problem seems to be that the API routes aren't even created and are therefore inaccessible. All the API routes worked a few weeks ago, but now they seem to have stopped working.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Check out this answer, it helped me solve a bug similar to yours. In my case when vercel was deploying my PR branch I was getting a 500 Internal Error. Once I merge the PR into main and vercel does a fresh deployment, I was now getting a 504 gateway error. The answer below helped me find out why.

https://stackoverflow.com/a/68774331/12775824

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda